<!DOCTYPE HTML><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
    <div class="content-box-header">
        <h3><? echo $title ?></h3><div class="clear"></div>
    </div><!-- End .content-box-header -->
    <div class="content-box-content">
        <?
        switch ($do) {
            case "add":add();break;
            case "update":update($rows);break;
            case "delete":delete($id);break;
            default: show_info($rows);
        }
        ?>
        <? function show_box($rows, $iseditmode){
            global $option, $h, $title, $url, $lang, $module;
                $str='';
            if($iseditmode){
                foreach($rows as $row){
                    if(is_enabled($row['level']))$str.='<tr>';
                    else $str.='<tr class="hide">';
                    $tem_value=d($row['name_'.$lang]);
                    $tem_level = d($row['level']);
                    $tem_discount = $row['discount'];
                    $tem_id = d($row['id']);
                    $tem_start_score = d($row['start_score']);
                    $tem_end_score = d($row['end_score']);
                    //$str.=$h->text('id_'.$row['id'], $tem_level,'g');
                    $str.='<td><input type="text" name="level_'.$tem_id.'"  value="'.$tem_level.'"/></td><td><input type="text" name="name_'.$lang.'_'.$tem_id.'" value="'.$tem_value.'"/></td><td><input type="text" style="width:36px"  name="discount_'.$tem_id.'" value="'.$tem_discount.'"/> %</td><td><input type="text" style="width:80px" name="start_'.$tem_id.'" value="'.$tem_start_score.'" /> - <input type="text" name="end_'.$tem_id.'" style="width:80px" value="'.$tem_end_score.'" /></td></tr>';
                }
                ?>
                <table width="99%" cellspacing="0" cellpadding="3" class="mlist set">
                    <tr class="th"><td width="240"><?=ROOT_CUSTOMER_LEVEL?></td><td><?=ROOT_CUSTOMER_NAME1?></td><td><?=ROOT_CUSTOMER_DISCOUNT?></td><td><?=ROOT_CUSTOMER_SCORE?></td></tr>
                    <? echo $str; ?>
                    <tr><td>&nbsp;</td><td><br><input class="<? echo $iseditmode==1?'button':'hide'?>" type="submit" value="&nbsp; <?=ROOT_SAVE?> &nbsp;"> &nbsp; <a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
<!--                    <tr><td class="l">&nbsp;</td><td><br><a href="--><?// echo $url ?><!--.php?do=update">[ --><?//=ROOT_EDIT_SETTING?><!-- ]</a><br><br></td></tr>-->
                </table>
            <?
            }
            else{
                foreach($rows as $row){
                    if(is_enabled($row['level']))$str.='<tr>';
                    else $str.='<tr class="hide">';
                    $tem_value=d($row['name_'.$lang]);
                    $tem_level = d($row['level']);
                    $tem_discount = d($row['discount']);
                    $tem_start_score = d($row['start_score']);
                    $tem_end_score = d($row['end_score']);
                    $tem_id = $row['id'];
                    $str.='<td>'.$tem_level.'</td><td>'.$tem_value.'</td><td>'.$tem_discount.'%</td><td>'.$tem_start_score.' - '.$tem_end_score.'</td><td><a href="'.$url.'.php?do=delete&id='.$tem_id.'" onClick="javascript: return delc();">'.ROOT_DELETE.'</a></td></tr>';
                }
                ?>
                <table width="99%" cellspacing="0" cellpadding="3" class="mlist set">
                    <tr class="th"><td width="240"><?=ROOT_CUSTOMER_LEVEL?></td><td><?=ROOT_CUSTOMER_NAME1?></td><td><?=ROOT_CUSTOMER_DISCOUNT?></td><td><?=ROOT_CUSTOMER_SCORE?></td><td></td></tr>
                    <? echo $str; ?>
                    <tr><td class="l">&nbsp;</td><td><br><a href="<? echo $url ?>.php?do=update">[ <?=ROOT_EDIT_SETTING?> ]</a><br><br></td><td><br><a href="<? echo $url ?>.php?do=add">[ <?=ROOT_ADD?> ]</a><br><br></td><td></td></tr>
                </table>
            <?
            }
        } ?>
        <?
        function add_box(){
            global $option, $h, $title, $url, $lang, $module;
            $str='<td><input type="text" name="level"  value=""/></td><td><input type="text" name="name'.$lang.'" value=""/></td><td><input type="text" style="width:36px" name="discount" value=""/> %</td><td><input type="text" name="start" value="" style="width:80px"  />&nbsp;-&nbsp;<input type="text" name="end" value="" style="width:80px" /></td></tr>';
            ?>

        <table width="99%" cellspacing="0" cellpadding="3" class="mlist set">
            <tr class="th"><td  width="240"><?=ROOT_CUSTOMER_LEVEL?></td><td><?=ROOT_CUSTOMER_NAME1?></td><td><?=ROOT_CUSTOMER_DISCOUNT?></td><td><?=ROOT_CUSTOMER_SCORE?></td></tr>
            <? echo $str; ?>
            <tr><td class="l">&nbsp;</td><td><br><input class="button" type="submit" value="&nbsp; <?=ROOT_SAVE?> &nbsp;"> &nbsp;   <a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
<!--        <tr><td class="l">&nbsp;</td><td><br><a href="--><?// echo $url ?><!--.php?do=add">[ --><?//=ROOT_SAVE?><!-- ]</a><br><br></td><td><br><a href="history.go(-1)">[ --><?//=ROOT_CANCEL?><!-- ]</a><br><br></td></tr>-->
        </table>
        <?
        }
        ?>

        <br class="clear" />
        <div><?=ROOT_CUSTOMER_RULE_DESCRIPTION?></div>
    </div> <!-- End .content-box-content -->

    <br class="clear" />
</div><!-- End .content-box -->
</body>
</html>
